package com.javatip.project.deep_learning.taskQueue.controller;

import com.javatip.framework.web.controller.BaseController;
import com.javatip.project.deep_learning.predict.domain.Predict;
import com.javatip.project.deep_learning.predict.service.IPredictService;
import com.javatip.project.deep_learning.trainMission.domain.TrainMission;
import com.javatip.project.deep_learning.trainMission.service.ITrainMissionService;
import com.javatip.project.queue.domain.Task;
import com.javatip.project.queue.service.QueueService;
import com.javatip.project.system.user.service.IUserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Api(tags = "任务队列")
@Controller
@RequestMapping("/deep_learning/taskQueue")
public class TaskQueueController extends BaseController {

    @Autowired
    private QueueService queueService;
    @Autowired
    private ITrainMissionService trainMissionService;

    @Autowired
    private IUserService userService;

    @Autowired
    private IPredictService predictService;

    private String prefix = "deep_learning/taskQueue";
    @GetMapping()
    public String taskQueue() {
        return prefix+ "/taskQueue";
    }

    /**
     * 获取status为待训练和训练中的训练任务列表，返回数组
     *
     * @return
     */
    @GetMapping("/getWaitAndTrainingList")
    @ResponseBody
//	返回数组
    public List<Task> getWaitAndTrainingList() {

//        startPage();
        List<Task> list = queueService.getAllTasksInOrder();
//        System.out.println("list: " + list);
//        添加归属用户

//        System.out.println("list: "+list);
        return list;
    }
//
//    @GetMapping("/getWaitAndPredictList")
//    @ResponseBody
////	返回数组
//    public List<Predict> getWaitAndPredictList() {
//        List<Predict> list = predictService.selectWaitAndPredictingList(null);
//        // 筛选出待识别和识别中的任务
//        for (Predict predict : list) {
//                // 添加归属用户
//                String userName = userService.selectUserById(predict.getUserId().longValue()).getUserName();
//                predict.setUserName(userName);
//        }
////        System.out.println("resultList: " + resultList);
//        return list;
//    }
}